package stud.aistar.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import stud.aistar.entity.Department;
import stud.aistar.entity.SecondDepartment;
import stud.aistar.service.IDepartmentService;
import stud.aistar.service.ISecondDepartmentService;

import java.util.List;

/**
 * Created by Administrator on 2019/10/16.
 */
@Controller
@RequestMapping("firstdep")
public class firastdepController {

    @Autowired
    private IDepartmentService departmentService;
    @Autowired
    private ISecondDepartmentService secondDepartmentService;

    @RequestMapping("dep")
    public String dep(Model model){
        List<Department> list = departmentService.findAll();

        model.addAttribute("fdepList",list);
        return "showmessage/firstdep";
    }

    @RequestMapping("sdep")
    public String sdep(Model model,String fid){
        List<SecondDepartment> list =secondDepartmentService.findByDeptId(Integer.valueOf(fid));
        System.out.println(list);

        model.addAttribute("sdepList",list);

        model.addAttribute("fid",fid);

        return "showmessage/secondDep";

    }

}
